rom 5e7ff518c12de6665bad24650e555b2c3b2304d0 Mon Sep 17 00:00:00 2001
From: Olivier Duchateau <duchateau.olivier@gmail.com>
Date: Sat, 25 Oct 2014 17:43:49 +0000
Subject: [PATCH] Add 'Hidden' option in exo desktop item editori (bug #11249).

--- exo-desktop-item-edit/exo-die-editor.c.orig	2012-12-27 12:50:31 UTC
+++ exo-desktop-item-edit/exo-die-editor.c
@@ -41,6 +41,7 @@
   PROP_PATH,
   PROP_SNOTIFY,
   PROP_TERMINAL,
+  PROP_HIDDEN,
 };
 
 
@@ -89,6 +90,7 @@
   gchar           *path;
   guint            snotify : 1;
   guint            terminal : 1;
+  guint            hidden : 1;
 };
 
 
@@ -240,6 +242,19 @@
                                                          "terminal",
                                                          FALSE,
                                                          EXO_PARAM_READWRITE));
+
+  /**
+   * ExoDieEditor:hidden:
+   *
+   * Hide desktop item in menu.
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_HIDDEN,
+                                   g_param_spec_boolean ("hidden",
+                                                         "hidden",
+                                                         "hidden",
+                                                         FALSE,
+                                                         EXO_PARAM_READWRITE));
 }
 
 
@@ -287,7 +302,7 @@
   editor->path = g_strdup ("");
 
   /* configure the table */
-  gtk_table_resize (GTK_TABLE (editor), 8, 2);
+  gtk_table_resize (GTK_TABLE (editor), 9, 2);
   gtk_table_set_col_spacings (GTK_TABLE (editor), 12);
   gtk_table_set_row_spacings (GTK_TABLE (editor), 0);
 
@@ -436,6 +451,14 @@
   exo_mutual_binding_new (G_OBJECT (editor), "terminal", G_OBJECT (button), "active");
   exo_binding_new_full (G_OBJECT (editor), "mode", G_OBJECT (button), "visible", exo_die_true_if_application, NULL, NULL);
   gtk_table_attach (GTK_TABLE (editor), button, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
+
+  row += 1;
+
+  /* Hidden button */
+  button = gtk_check_button_new_with_label (_("Hide from menus"));
+  exo_mutual_binding_new (G_OBJECT (editor), "hidden", G_OBJECT (button), "active");
+  exo_binding_new_full (G_OBJECT (editor), "mode", G_OBJECT (button), "visible", exo_die_true_if_application, NULL, NULL);
+  gtk_table_attach (GTK_TABLE (editor), button, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
 }
 
 
@@ -508,6 +531,10 @@
       g_value_set_boolean (value, exo_die_editor_get_terminal (editor));
       break;
 
+    case PROP_HIDDEN:
+      g_value_set_boolean (value, exo_die_editor_get_hidden (editor));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -562,6 +589,10 @@
       exo_die_editor_set_terminal (editor, g_value_get_boolean (value));
       break;
 
+    case PROP_HIDDEN:
+      exo_die_editor_set_hidden (editor, g_value_get_boolean (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -674,6 +705,7 @@
   ExoDieEditor *editor = EXO_DIE_EDITOR (user_data);
   gboolean      terminal;
   gboolean      snotify;
+  gboolean      hidden;
   gchar        *comment;
   gchar        *command;
   gchar        *icon;
@@ -691,6 +723,7 @@
                       EXO_DIE_DESKTOP_MODEL_COLUMN_NAME, &name,
                       EXO_DIE_DESKTOP_MODEL_COLUMN_SNOTIFY, &snotify,
                       EXO_DIE_DESKTOP_MODEL_COLUMN_TERMINAL, &terminal,
+                      EXO_DIE_DESKTOP_MODEL_COLUMN_HIDDEN, &hidden,
                       -1);
 
   /* apply the settings to the editor */
@@ -700,6 +733,7 @@
   exo_die_editor_set_icon (editor, (icon != NULL) ? icon : "");
   exo_die_editor_set_snotify (editor, snotify);
   exo_die_editor_set_terminal (editor, terminal);
+  exo_die_editor_set_hidden (editor, hidden);
   exo_die_editor_set_path (editor, "");
 
   /* cleanup */
@@ -1333,5 +1367,46 @@
 
 
 
+/**
+ * exo_die_editor_get_hidden:
+ * @editor : an #ExoDieEditor.
+ *
+ * Returns %TRUE if the desktop item should be hidden, only valid
+ * if mode for @editor is %EXO_DIE_EDITOR_MODE_APPLICATION.
+ *
+ * Return value: %TRUE if desktop item should be hidden.
+ **/
+gboolean
+exo_die_editor_get_hidden (ExoDieEditor *editor)
+{
+  g_return_val_if_fail (EXO_DIE_IS_EDITOR (editor), FALSE);
+  return editor->hidden;
+}
+
+
+
+/**
+ * exo_die_editor_set_hidden:
+ * @editor   : an #ExoDieEditor.
+ * @hidden : %TRUE hide desktop item.
+ *
+ **/
+void
+exo_die_editor_set_hidden (ExoDieEditor *editor,
+                             gboolean      hidden)
+{
+  g_return_if_fail (EXO_DIE_IS_EDITOR (editor));
 
+  /* normalize the value */
+  hidden = !!hidden;
 
+  /* check if we have a new value */
+  if (editor->hidden != hidden)
+    {
+      /* apply the new value */
+      editor->hidden = hidden;
+
+      /* notify listeners */
+      g_object_notify (G_OBJECT (editor), "hidden");
+    }
+}
